package calao;

import calao.client.MissingPermissionException;
import calao.client.Permission;

public class DesktopServiceImpl 
extends Service 
{

	/** Gets the session associated with the thread local request.
	 */
	protected Session getThreadLocalSession()
	{
		return getThreadLocalRequest().getSession();
	}

	/** Gets the thread local request.
	 */
	protected WebRequest getThreadLocalRequest()
	{
		return WorkspaceServlet.getThreadLocalRequest();
	}

	protected void check(Permission perm)
	throws MissingPermissionException
	{
		Session session = getThreadLocalSession();
		if (session!=null && !session.has(perm)) {
			throw new MissingPermissionException();
		}
	}

}
